import request from '@/request.js'


export const getfoodservice = (type) => {
    const queryParams = new URLSearchParams();
    queryParams.append('type', type); // 将用户名添加到查询字符串中

    const url = `/food/getfood?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);
}

export const userorder = (data) => {
    const params=new URLSearchParams();
    for(let key in data){
        params.append(key,data[key])
    }
    return request.post('/food/orderfood',params)

}

export const getordersevice = () => {

    return request.post('/food/getorder')

}
export const getamountpriceservice = () => {

    return request.post('/food/getamountprice')

}
export const changeorder = (data) => {
    const params=new URLSearchParams();
    for(let key in data){
        params.append(key,data[key])
    }
    return request.post('/food/changeorder',params)

}
export const deletorderDetailservice = (itemId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('itemId', itemId); // 将用户名添加到查询字符串中

    const url = `/food/deletorderdetail?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);
}


export const updateorDerstatusservice = () => {

    return request.post('/food/updateorderstatus')
}

export const modifysalesService = (itemId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('itemId', itemId); // 将用户名添加到查询字符串中

    const url = `/food/modifysales?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);
}
export const searchfoodservice = (input) => {
    const queryParams = new URLSearchParams();
    queryParams.append('itemname', input); // 将用户名添加到查询字符串中

    const url = `/food/searchfood?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);
}


export const spikesordeservice = (data) => {
    const params=new URLSearchParams();
    for(let key in data){
        params.append(key,data[key])
    }
    return request.post('/food/spikesorder',params)

}

export const getmenupackservice = () => {

    return request.post('/food/getmenupack')
}



export const getcommentservice = (itemid) => {
    const queryParams = new URLSearchParams();
    queryParams.append('itemid', itemid); // 将用户名添加到查询字符串中

    const url = `/food/getcomment?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);
}

export const getdowncommentservice = (id,itemid) => {
    const queryParams = new URLSearchParams();
    queryParams.append('id', id); // 将用户名添加到查询字符串中
    queryParams.append('itemid', itemid);
    const url = `/food/getdowncomment?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);
}
export const getuserdetailservice = (userId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('userId',userId); // 将用户名添加到查询字符串中
    const url = `/food/getuserdetail?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);
}
export const insertcommentservice = (commenttext,rating,id,itemId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('commenttext',commenttext); // 将用户名添加到查询字符串中
    queryParams.append('rating',rating); // 将用户名添加到查询字符串中
    queryParams.append('pid',id); // 将用户名添加到查询字符串中
    queryParams.append('itemId',itemId); // 将用户名添加到查询字符串中
    const url = `/food/insertcomment?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);


}
export const getaplyedorderdetaiservice = () => {

    return request.post('/food/findorderdetail')
}
export const getaplyedorderaomuntservice = () => {

    return request.post('/food/getorderdetailamount')
}
export const findorderidByuseridandnumberservice = () => {

    return request.post('/food/findorderidByuseridandnumber')
}
export const findorderstatusByuseridandnumberservice = () => {

    return request.post('/food/findorderstatusByuseridandnumber')
}
export const findorderstatusByuseridservice = () => {

    return request.post('/food/findorderByuserid')
}

export const getitemlistbyorderIdservice = (orderId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('orderId', orderId); // 将用户名添加到查询字符串中

    const url = `/food/finditemlistByOrderId?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);
}

export const getaplyedorderdetaibyorderIdservice = (orderId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('orderId', orderId); // 将用户名添加到查询字符串中

    const url = `/food/findorderdetailbyorderId?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);
}
export const getaplyedorderaomuntbyorderIdservice = (orderId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('orderId', orderId); // 将用户名添加到查询字符串中

    const url = `/food/getorderdetailamountbyorderId?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);

}
export const findorderstatusbyorderIdservice = (orderId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('orderId', orderId); // 将用户名添加到查询字符串中

    const url = `/food/findorderstatusByorderId?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);


}
export const findcouponsByuseridservice = () => {

    return request.post('/food/getcouponByuserId')
}
export const changepriceservice = (selectvalue) => {
    const queryParams = new URLSearchParams();
    queryParams.append('couponId', selectvalue); // 将用户名添加到查询字符串中

    const url = `/food/getcouponsamounts?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);

}

export const findallcouponsservice = () => {

    return request.post('/food/getallcoupons')
}
export const getuserallroleservice = () => {

    return request.post('/food/getuserallrole')
}
export const getcouponsservice = (couponId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('couponId', couponId); // 将用户名添加到查询字符串中

    const url = `/food/getcoupons?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);

}
export const getrecommenditemservice = () => {

    return request.post('/food/getrecommenditem')
}
export const insertorderdetailByitempackservice = (data) => {
    const params=new URLSearchParams();
    for(let key in data){
        params.append(key,data[key])
    }
    return request.post('/food/insertorderdetailBypackItem',params)
}
export const getmenuitemListBypackIdservice = (packId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('packId', packId); // 将用户名添加到查询字符串中

    const url = `/food/getmenuitemBypackId?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);

}
export const getmenuitemListByrecommendByitemIdservice = (itemId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('itemId', itemId); // 将用户名添加到查询字符串中

    const url = `/food/getitemListByrecomenditemId?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);

}
export const getitemListBysalasservice = () => {

    return request.post('/food/getmenListBysalas')
}
export const getitemListByavageratingservice = () => {

    return request.post('/food/getmenuListByavagerating')
}

export const deletorderandorderdeTaliByorderIDservice = (orderId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('orderId', orderId); // 将用户名添加到查询字符串中

    const url = `/food/deleleorderandorderDetailByorderId?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);




}



//这里开始时后台管理的接口
export const getalluserservice = () => {
    return request.post('/food/getalluser')
}


export const updateusernamepasswordservice = (username,password) => {
    const queryParams = new URLSearchParams();
    queryParams.append('username', username); // 将用户名添加到查询字符串中
    queryParams.append('password', password);
    const url = `/food/updatepasswordByusername?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);




}

export const updateuserdetailservice = (id,username,email,phone,age,imageUrl) => {
    const queryParams = new URLSearchParams();
    queryParams.append('id', id);
    queryParams.append('username', username);
    queryParams.append('email', email);
    queryParams.append('phone', phone);
    queryParams.append('age', age);
    queryParams.append('imageurl', imageUrl);
    console.log(queryParams)
    const url = `/food/updateuser?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);

}
export const getallroleservice = () => {
    return request.post('/food/getallRolemange')
}
export const getroleBytheusernameservice = (username) => {
    const queryParams = new URLSearchParams();
    queryParams.append('username', username);
    const url = `/food/getroleByusername?${queryParams.toString()}`; // 将查询字符串添加到 URL 中
    return request.post(url);
}

export const insertroleByRoleIdService = (roleId, userId) => {
    const data = {
        roleid: Array.isArray(roleId) ? roleId : [roleId], // 确保roleid始终为数组
        userid: userId
    };

    return request.post('/food/insertuserRoleByuseridandroleid', data);
}

export const updateuserstatesservice = (id) => {
    const queryParams = new URLSearchParams();
    queryParams.append('userid', id); // 将用户名添加到查询字符串中
    const url = `/food/updateuserStatus?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);


}
export const getallmenulistservice = () => {
    return request.post('/food/getmenuitemList')
}

export const insertmenuBybakgroundService = (item) => {
    const menuItem = item;

    return request.post('/food/insertmenuBybakground',menuItem);
}
export const getolditemByidservice = (id) => {
    const queryParams = new URLSearchParams();
    queryParams.append('itemId', id); // 将用户名添加到查询字符串中
    const url = `/food/getitemByitemId?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);


}

export const updateitemBybakgroundService = (item) => {
    const menuItem = item;

    return request.post('/food/updateitemByitem',menuItem);
}

export const updateitemspecialPriceandtypeandquantityByitemIdService = (item) => {
    const menuItem = item;

    return request.post('/food/updateitemspecialPriceandtypeandquantityByitemId',menuItem);
}
export const ideleteitemByidservice = (id) => {
    const queryParams = new URLSearchParams();
    queryParams.append('itemId', id); // 将用户名添加到查询字符串中
    const url = `/food/updateitemstatusByitemId?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);


}

export const updatepriceByidservice = (id,price) => {
    const queryParams = new URLSearchParams();
    queryParams.append('itemId', id);
    queryParams.append('price', price);
    const url = `/food/updateitempriceByitemid?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);


}

export const getallorderBybackgroundservice = () => {
    return request.post('/food/getorderBybackground')
}

export const updateorderstatusByidservice = (orderId,status) => {
    const queryParams = new URLSearchParams();
    queryParams.append('orderId', orderId.value);
    queryParams.append('status', status.value);
    const url = `/food/updateorderstatusByorderId?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);

}
export const sendmessageTouserservice = (message,userId,orderId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('message', message);
    queryParams.append('userId', userId);
    queryParams.append('orderId', orderId);
    const url = `/food/sentmessageByredis?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);

}
export const getmanagemessageservice = () => {
    return request.post('/food/getmessageByredis')
}
export const sendmessageToitemservice = (message,type,Discount) => {
    const queryParams = new URLSearchParams();
    queryParams.append('message', message);
    queryParams.append('type', type);
    queryParams.append('Discount',  Discount);
    const url = `/food/sentitemmessageByredis?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);

}
export const getdiscountpricemessageservice = () => {
    return request.post('/food/getItemdiscountpricemessage')
}
export const recoveritempriceservice = () => {
    return request.post('/food/recoveritemorice')
}
export const getallcouponsBybackgroundservice = () => {
    return request.post('/food/getallcouponsBybackground')
}
export const insertcouponService = (coupon) => {

    return request.post('/food/insertcoupon', coupon);
}
export const getcouponservice = (id) => {
    const queryParams = new URLSearchParams();
    queryParams.append('couponId', id);
    const url = `/food/getcouponByid?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);

}


export const updatecouponService = (coupon) => {

    return request.post('/food/updatecoupon', coupon);
}
export const sentcouponToUserservice = (userId,couponId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('userId', userId.value);
    queryParams.append('couponId', couponId.value);
    const url = `/food/setcouponTouser?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);

}
export const getcouponmessageService = (coupon) => {

    return request.post('/food/getcouponmessage', coupon);
}
export const getuserlistBycouponidservice = (couponId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('couponId', couponId);
    const url = `/food/finduserBYcouponId?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);

}

export const deletUsercouponservice = (couponId,userId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('couponId', couponId.value);
    queryParams.append('userId', userId.value);
    const url = `/food/deleteUsercouponByuserIdandcouponId?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);

}
export const deletcouponservice = (couponId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('id', couponId);
    const url = `/food/delercoupon?${queryParams.toString()}`; // 将查询字符串添加到 URL 中
    return request.post(url);

}
export const getcallcommenrService = () => {
    return request.post('/food/getallrcomment');
}

export const replyusercommentservice = (comment,pid,itemId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('comment', comment);
    queryParams.append('pid', pid);
    queryParams.append('itemId', itemId);
    const url = `/food/insertcommentByidanditemid?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);

}
export const updateweightservice = (id,itemId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('id', id);
    queryParams.append('itemId', itemId);
    const url = `/food/updatecommentweightByid?${queryParams.toString()}`; // 将查询字符串添加到 URL 中

    return request.post(url);

}

export const deletcommentservice = (id) => {
    const queryParams = new URLSearchParams();
    queryParams.append('id', id);
    const url = `/food/updatecommentisdeleteByid?${queryParams.toString()}`; // 将查询字符串添加到 URL 中
    return request.post(url);

}
export const getallitempackService = () => {
    return request.post('/food/getallitempackBybackground');
}
export const insertitempackBybakgroundservice = (description,imageUrl) => {
    const queryParams = new URLSearchParams();
    queryParams.append('description', description.value);
    queryParams.append('imageUrl', imageUrl.value);
    const url = `/food/insertitempackBybakground?${queryParams.toString()}`; // 将查询字符串添加到 URL 中
    return request.post(url);

}

export const updateitempackservice = (id,description,imageUrl) => {
    const queryParams = new URLSearchParams();
    queryParams.append('id', id.value);
    queryParams.append('description', description.value);
    queryParams.append('imageUrl', imageUrl.value);
    const url = `/food/updateitempackdescriptionByid?${queryParams.toString()}`; // 将查询字符串添加到 URL 中
    return request.post(url);

}

export const getitemlistBypackidservice = (packId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('packId', packId);
    const url = `/food/getimenuListByitemPackId?${queryParams.toString()}`; // 将查询字符串添加到 URL 中
    return request.post(url);

}
export const getallpriceBypackIdservice = (packId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('packId', packId.value);
    const url = `/food/getallpriceBypackId?${queryParams.toString()}`; // 将查询字符串添加到 URL 中
    return request.post(url);

}
export const deleteitempackItemservice = (itemId,packId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('itemId', itemId);
    queryParams.append('packId', packId.value);
    const url = `/food/deletepackitemItemByitemIdandpackId?${queryParams.toString()}`; // 将查询字符串添加到 URL 中
    return request.post(url);

}

export const additempackitemservice = (itemId,packId) => {
    const queryParams = new URLSearchParams();
    queryParams.append('itemId', itemId);
    queryParams.append('packId', packId);
    const url = `/food/insertpackitemItemByitemIdandpackId?${queryParams.toString()}`; // 将查询字符串添加到 URL 中
    return request.post(url);

}
export const updateitempakcpricemservice = (id,allprice) => {
    const queryParams = new URLSearchParams();
    queryParams.append('id', id);
    queryParams.append('allprice', allprice);
    const url = `/food/updateitempackallpriceByid?${queryParams.toString()}`; // 将查询字符串添加到 URL 中
    return request.post(url);

}

export const discountitempackpriceservice = (id,account) => {
    const queryParams = new URLSearchParams();
    queryParams.append('id', id);
    queryParams.append('account', account);
    const url = `/food/updeteitempackallpriceByaccountandid?${queryParams.toString()}`; // 将查询字符串添加到 URL 中
    return request.post(url);

}
export const discontallitempackService = (account) => {
    const queryParams = new URLSearchParams();
    queryParams.append('account', account.value);
    const url = `/food/updateallitempackallpriceByaccountandid?${queryParams.toString()}`; // 将查询字符串添加到 URL 中
    return request.post(url);


}
export const deletitempackService = (id) => {
    const queryParams = new URLSearchParams();
    queryParams.append('id', id);
    const url = `/food/updateitempackisdeleteByid?${queryParams.toString()}`; // 将查询字符串添加到 URL 中
    return request.post(url);

}
export const gettodayoerderamountService = () => {
    return request.post('/food/gettaldayorderaomunt');
}

export const getbetterpercentService = () => {
    return request.post('/food/getbetterOrderpercent');
}
export const getyesdayoerderamountService = () => {
    return request.post('/food/getyesterdayorderaomunt');
}

export const menulistBysalsasLimtetenService = () => {
    return request.post('/food/menulistBysalsasLimteten');
}
export const getcommentListService = () => {
    return request.post('/food/itemcommentListByuserId');
}

export const getcommentReplyListService = (pid) => {
    const queryParams = new URLSearchParams();
    queryParams.append('pid', pid);
    const url = `/food/getitemcommentByuserIdandpid?${queryParams.toString()}`; // 将查询字符串添加到 URL 中
    return request.post(url);
}
export const getbestcouponService = (price) => {
    const queryParams = new URLSearchParams();
    queryParams.append('price', price);
    const url = `/food/getbestcoupon?${queryParams.toString()}`; // 将查询字符串添加到 URL 中
    return request.post(url);
}

export const deleteOrderanOrderdetailService = () => {
    return request.post('/food/deleteorderandorderDetailByuserId');
}